﻿using Aker.DevTeam;
using DevExpress.XtraReports.UI;
using System;
using System.Data;

namespace Aker.Uretim
{
    public partial class ImalatReport11 : DevExpress.XtraReports.UI.XtraReport
    {
        private string ProductId;
        string detailTableName;
        ReportPrintTool printTool;
        private DataSet ds;
        int type = 0;

        public ImalatReport11()
        {
            InitializeComponent();
            printTool = new ReportPrintTool(this);
            this.ShowPrintMarginsWarning = false;
        }

        public void ArtikelRaporu(int ProductId)
        {
            //Type = Mevcut kayıt 
            type = 1;
            ds = Data.DM.ExecuteDataSet("GetKumasImalatFoyu", DBNull.Value, ProductId);
            Bind();
        }

        public void SiparisFormuRaporu(int POrderLinesId)
        {
            //Type = Yeni kayıt
            type = 2;
            ds = Data.DM.ExecuteDataSet("GetKumasImalatFoyu", POrderLinesId, DBNull.Value);
            Bind();
        }


        private void Bind()
        {
            this.DataSource = ds;
            this.DataMember = detailTableName;
            DataRow drHeader = ds.Tables[0].Rows[0];
            ProductId = drHeader["ProductId"].ToStringNN();
            detailTableName = ds.Tables[0].TableName;
            lblMusteri.Text = drHeader["Musteri"].ToStringNN();
            lblSipNo.Text = drHeader["SiparisNo"].ToStringNN();
            if (drHeader["QtyManuel"].ToStringNN() == "")
                lblSipMiktari.Text = drHeader["SiparisMiktari"].ToDecimalNN().ToString("n2") + " " + drHeader["Birim"].ToStringNN();
            else
                lblSipMiktari.Text = drHeader["QtyManuel"].ToDecimalNN().ToString("n2");

            if (drHeader["Termin"].ToStringNN() != "")
                lblTermin.Text = ((DateTime)(drHeader["Termin"])).ToShortDateString();
            else
                lblTermin.Text = "";
            DateTime drModifiedOn = (DateTime)drHeader["ModifiedOn"];

            if (type == 1) //mevcut
            {
                lblDate.Text = drModifiedOn.ToShortDateString();
                lblTime.Text = drModifiedOn.ToLongTimeString();
            }
            else //yeni
            {
                lblDate.Text = DateTime.Now.ToShortDateString();
                lblTime.Text = DateTime.Now.ToLongTimeString();
            }

            lblGirisGr.Text = drHeader["GirisGr"].ToStringNN();
            lblSiklik.Text = drHeader["SIKLIK"].ToStringNN();
            lblHiz.Text = drHeader["Hiz"].ToStringNN();
            lblSardon.Text = drHeader["SardonTipi"].ToStringNN();
            lblRam.Text = drHeader["Ram"].ToStringNN();
            lblFinalGramaj.Text = drHeader["FinishGr"].ToStringNN();
            lblFinalEn.Text = drHeader["FinalEn"].ToStringNN();
            lblArtikelNo.Text = drHeader["Artikel"].ToStringNN();
            lblKompozisyon.Text = drHeader["Kompozisyon"].ToStringNN();
            lblDesen.Text = drHeader["DesenNo"].ToStringNN();
            lblAciklama.Text = drHeader["Aciklama"].ToStringNN();
            lblIp1.Text = drHeader["Ip1"].ToStringNN();
            lblIp2.Text = drHeader["Ip2"].ToStringNN();
            lblIp3.Text = drHeader["Ip3"].ToStringNN();
            lblIp4.Text = drHeader["Ip4"].ToStringNN();
            lblLycra.Text = drHeader["Lycra"].ToStringNN();
            lblPartiNo.Text = drHeader["PartiNo"].ToStringNN();
            lblParlatma.Text = drHeader["Parlatma"].ToStringNN();
            lblFirca.Text = drHeader["Firca"].ToStringNN();
            lblTip.Text = drHeader["BaskiTipi"].ToStringNN();
            lblBaski.Text = drHeader["Baski"].ToStringNN();
            lblReferansArtikel.Text = drHeader["ReferansArtikel"].ToStringNN();
            lblBaskici.Text = drHeader["Baskici"].ToStringNN();
            lblBoyahane.Text = drHeader["Boyahane"].ToStringNN();
            lblPus.Text = drHeader["Pus"].ToStringNN();
            lblFayn.Text = drHeader["Fine"].ToStringNN();
            lblSistem.Text = drHeader["Sistem"].ToStringNN();
            lblMakineCinsi.Text = drHeader["OrmeMakinesiId"].ToStringNN();
            lblOrmeci.Text = drHeader["Ormeci"].ToStringNN();
            //lblCekmezlik.Text = drHeader["Cekmezlik"].ToStringNN();
            //lblYikamaHasligi.Text = drHeader["YikamaHasligi"].ToStringNN();
            //lblSurtHasligi.Text = drHeader["SurtHasligi"].ToStringNN();
            //lblYikamaTalimati.Text = drHeader["YikamaTalimati"].ToStringNN();
        }
    }
}
